package com.grechur.wanandroidcompose.widget.smartrefresh.theme

import androidx.annotation.FloatRange
import androidx.annotation.IntRange
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.grechur.wanandroidcompose.widget.smartrefresh.NestedScrollMode
import com.grechur.wanandroidcompose.widget.smartrefresh.SmartSwipeRefreshState
import com.grechur.wanandroidcompose.widget.smartrefresh.indicator.SwipeRefreshFooter
import com.grechur.wanandroidcompose.widget.smartrefresh.indicator.SwipeRefreshHeader

object SmartSwipeRefreshTheme {
    var config by mutableStateOf(SmartSwipeRefreshConfig())
}

data class SmartSwipeRefreshConfig(
    val headerScrollMode: NestedScrollMode = NestedScrollMode.Translate,
    val footerScrollMode: NestedScrollMode = NestedScrollMode.Translate,
    val refreshEnabled: Boolean = true,
    val loadMoreEnabled: Boolean = true,
    @FloatRange(from = 0.0, fromInclusive = false) val refreshTriggerRate: Float = 1f,
    @FloatRange(from = 0.0, fromInclusive = false) val loadMoreTriggerRate: Float = 1f,
    @FloatRange(from = 1.0) val headerMaxOffsetRate: Float = 2f,
    @FloatRange(from = 1.0) val footerMaxOffsetRate: Float = 2f,
    @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) val dragMultiplier: Float = 0.5f,
    @IntRange(from = 0, to = 2000) val finishDelayMillis: Long = 500,
    val vibrateEnabled: Boolean = false,
    val headerIndicator: @Composable (SmartSwipeRefreshState) -> Unit = {
        SwipeRefreshHeader(it)
    },
    val footerIndicator: @Composable (SmartSwipeRefreshState) -> Unit = {
        SwipeRefreshFooter(it)
    },
)